package com.dao.impl;

import com.dao.CommentDao;
import com.dao.RedisGeneratorDao;
import com.entity.Condition;
import com.entity.Comment;
import com.entity.CommentExample;
import com.mapper.CommentMapper;
import com.page.PageInfo;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Repository
public class CommentDaoImpl implements CommentDao {
    @Resource
    CommentMapper commentMapper;



    public List<Comment> getCommentsByCmpid(Integer cmpid){
        return commentMapper.getCommentsByCmpid(cmpid);
    }
    /**
     * 普通分页查询
     * @param pageInfo
     * @return
     */
    public List<Comment> getCommentsByPage(PageInfo pageInfo){
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("currPage",pageInfo.getCurrPage());
        map.put("pageSize",pageInfo.getPageSize());
        int itemCount = (int)commentMapper.countByExample(null);
        pageInfo.setItemCount(itemCount);
       return null;
        //  return commentMapper.getCommentsByPage(map);
    }





    /**
     *
     * @param cmid
     * @return
     */
    public Comment getCommentByCmid(Integer cmid) throws Exception{
        return commentMapper.selectByPrimaryKey(cmid);
    }

    /**
     *
     * @param comment
     */
    public Integer add(Comment comment)throws Exception{
        return commentMapper.insertSelective(comment);//是使用selective 有值才插入
    }

    public Integer update(Comment comment)throws Exception{
        return commentMapper.updateByPrimaryKeySelective(comment);//是使用selective 有值才插入
    }



}
